package b_sorting_advance.a_merge_sort;

import utils.ArrayGeneric;
import utils.sorting_helper.SortingTest;

@SuppressWarnings("unchecked")
public class InsertionSort extends SortingTest {

    @Override
    public void sort(ArrayGeneric arr) {
        int len = arr.length();
        for (int i = 1; i < len; i++) {
            Comparable e = arr.get(i);
            int j;
            for (j = i; j > 0 && arr.get(j - 1).compareTo(e) > 0; j--) {
                arr.put(j, arr.get(j - 1));
            }
            arr.put(j, e);
        }
    }
}
